// ============================== 导入依赖 ============================== //

import DAY from './UTIL/day'

// ============================== 导出时间配置 ============================== //

const TIME = {
  /**
   * 初始时间戳
   */
  initstamp: Date.now(),

  /**
   * 动态时间戳
   */
  timestamp: Date.now(),

  /**
   * 日期
   */
  date: DAY.today(),

  /**
   * 时间
   */
  time: DAY.now().slice(11),

  /**
   * 星期
   */
  week: DAY.weekCN(Date.now()),

  /**
   * 秒数
   */
  second: 0,

  /**
   * 是否已停止秒数递增
   */
  stoped: false,
}

export default TIME

// ============================== 内部定时器 ============================== //

setInterval(() => {
  TIME.timestamp = Date.now()
  TIME.date = DAY.today()
  TIME.time = DAY.now().slice(11)
  TIME.week = DAY.weekCN(Date.now())
  if (!TIME.stoped) TIME.second = (TIME.timestamp - TIME.initstamp) / 1000 | 0
}, 1000)
